<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-fl">新增设备</div>
                    <div class="widget-function am-fr">
                        <a href="javascript:;" class="am-icon-cog"></a>
                    </div>
                </div>
                <div class="widget-body am-fr">
                    <form class="am-form tpl-form-line-form" id="productForm" method="post" >
                        <input type="hidden" id="id"  name="id" th:value="${record.id}"/>
                        <div class="am-form-group">
                            <label for="title" class="am-u-sm-2 am-form-label">名称
                                <span class="tpl-form-line-small-title">Title</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="title" class="tpl-form-input" placeholder="请输入标题" name="title" th:value="${record.title}"/>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="keyWords" class="am-u-sm-2 am-form-label">牌照
                                <span class="tpl-form-line-small-title">KeyWord</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="keyWords" class="tpl-form-input" placeholder="请输入关键字" name="keyWords" th:value="${record.keyWords}"/>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="descs" class="am-u-sm-2 am-form-label">型号
                                <span class="tpl-form-line-small-title">Description</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input type="text" id="descs" class="tpl-form-input" placeholder="请输入描述" name="descs" th:value="${record.descs}"/>
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="descs" class="am-u-sm-2 am-form-label">封面图
                                <span class="tpl-form-line-small-title">Description</span>
                            </label>
                            <div class="am-u-sm-10">
                                <input id="upFile" type="file"  />
                                <input id="coverImg" type="hidden"  name="coverImg" th:value="${record.coverImg}"/>
                            </div>
                        </div>
                        <div class="am-form-group">
                            <label for="user-intro" class="am-u-sm-2 am-form-label">是否可用</label>
                            <div class="am-u-sm-10">
                                <div class="tpl-switch">
                                    <input type="checkbox" class="ios-switch bigswitch tpl-switch-btn am-margin-top-xs"  th:checked="${record.isShow eq '1'}"  name="isShow"/>
                                    <div class="tpl-switch-btn-view">
                                        <div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>

                        <div class="am-form-group">
                            <div class="am-u-sm-10 am-u-sm-push-2">

                                <button type="button" onclick="return doSubmit();"
                                        class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                                <button type="button" onclick="loadPage('product/listUI')"
                                        class="am-btn am-btn-success tpl-btn-bg-color-success ">返回</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

</div>
<script th:inline="javascript">
    <![CDATA[
    //$('select').selected();
    validateUserForm();
    function validateUserForm(){
        valdater=$('#productForm').validate({
            errorElement : 'span',
            errorClass : 'am-icon-times',
            focusInvalid : true,
            onkeyup:false,
            ignore : "",
            rules : {
                title : {
                    required : true
                }
            },
            messages : {
                name : {
                    required : "请填写标题"
                }
            }
        });
    }

    function doSubmit(){
        if(valdater.form()){
            commit('productForm', 'product/save', 'product/listUI');
            return true;
        }
        return false;
    }

    var initImg = [];
    var img = [[${record.coverImg != null?record.coverImg:''}]];

    if(img!=''){
        initImg.push("<img height='160px' src='" + img + "' class='file-preview-image' alt='' title=''>");
    }
    initUpFileOne('upFile','coverImg','添加封面图片',initImg);

    ]]>
</script>